#include "Ps3Joystick.hpp"
#include "WPILib.h"

/**
 *  Constructor for Ps3Joystick.
 * 	
 * 	@param joystickPort The port number that the PlayStation 3 controller is plugged into.
 */
Ps3Joystick::Ps3Joystick(int joystickPort) :
	Joystick(joystickPort)
{
}

/**
 *  Destructor for Ps3Joystick.
 */
Ps3Joystick::~Ps3Joystick()
{
}

/**
 *  Get the current value of the specified axis.
 *  
 *  If this is giving you weird results for the right analog stick's X axis, try GetAxisValue(3).
 *  
 *  @param axis The Ps3Axis to read from.
 *  @return The current value of the axis.
 */
double Ps3Joystick::GetAxisValue(Ps3Axis axis)
{
	if(axis != kRightX)
		return GetRawAxis(axis);
	else	//you don't want to know (don't ask sam)
	{
		if(GetRawAxis(axis) < - 0.6)
			return (1/(1 - 0.6)) * (GetRawAxis(axis) + 0.6);
		else if(GetRawAxis(axis) > 0.6)
			return (1/(1 - 0.6)) * (GetRawAxis(axis) - 0.6);
		else
			return 0;
	}
}

/**
 *  Get the current value of the specified axis.
 *  
 *  @param axis A number representing the axis to read from.
 *  @return The current value of the axis.
 */
double Ps3Joystick::GetAxisValue(int axis)
{
	return GetRawAxis(axis);
}

/**
 *  Get the current value of the specified button.
 *  
 *  @param button The Ps3Button to read from.
 *  @return The value of the button.
 */
bool Ps3Joystick::GetButton(Ps3Button button)
{
	return GetRawButton(button);
}
